<template>
  <div
    @wheel.stop="handleScroll"
    class="jy-style-height Cultural-box"
    :style="{
      'background-image': `url(${publicUrls + 'free/style5/copyrightBg1.png' + '?imageView2/3/format/webp'})`,
    }"
  >
    <div class="copyright-heard">
      <i class="freeIcon" @click="blankHome">&#xe642;</i>
      <div class="heard-title">
        <i class="iconfonts">&#xe67c;</i>
        <span>文创商品</span>
        <i class="iconfonts">&#xe67c;</i>
      </div>
    </div>
    <ScrollBoxCom
      color="rgba(50, 43, 37, 1)"
      :scrollSrc="publicUrls + 'free/style5/pen2.png'"
      v-if="Scrollwidth"
      :byid="9867"
      :width="getScrollWidth"
    >
      <template #solidBorderExcon>
        <div
          class="right-scroll"
          ref="scrollBox"
          :style="list?.length <= 4 && { justifyContent: 'center', paddingLeft: '0px' }"
        >
          <div class="is-null" v-if="list.length === 0 && !loading"><span>暂无文创商品</span></div>
          <!-- <div class="is-null" v-if="list.length === 0 && !loading"><span>暂无文创商品</span></div> -->
          <div class="item-parent" v-for="(item, index) in list" :key="item.id">
            <div class="item" :class="{ 'item-1': index === 0, 'item-max': index === list.length - 1 }">
              <div class="item-img-box" @click="pathLink(item.url)">
                <img
                  class="item-img t-image t-image--fit-cover t-image--position-center"
                  v-if="!item.coverUrl"
                  src="http://101.34.143.36:8890/api/image/387939155165253"
                  alt=""
                /> 
                <img
                  class="item-img t-image t-image--fit-cover t-image--position-center"
                  v-else
                  :src="$filters.getLinkUrl(item.coverUrl + '?imageView2/3/format/webp')"
                  alt=""
                />
              </div>
              <p class="item-name">{{ item.name }}</p>
              <div class="item-btm">
                <span class="item-title1" v-if="item.price">￥</span>
                <span class="item-title2" v-if="item.price">{{ item.price }}</span>
                <span class="item-title3" v-if="item.price">参考价</span>
                <span class="item-title4" v-if="!item.price">暂无价格</span>
              </div>
            </div>
          </div>
        </div>
      </template>
      <template #solidBorderExbar>
        <div class="solidBorder-child"></div>
      </template>
    </ScrollBoxCom>  
     <a  
      :href="doorUrl"
      target="blank"
      class="logo-box"
      :style="{
        'background-image': `url(${publicUrls + 'free/style5/template5Logobg.png' + '?imageView2/3/format/webp'})`,
      }"
    ></a>
  </div>
  <MenuNavigation />  
  
</template>   

<script lang="ts">
export default defineComponent({
  name: 'style1',
});
</script>

<script setup lang="ts">
// @ts-nocheck
import MenuNavigation from '@/freeComponents/menuNavigation/index.vue';
import { publicUrls ,doorUrl} from '@/utils/minxin';
import { goodsList } from '@/api/goods/goods';
import RightMenu from '../components/rightMenu.vue';
import Logo from '../components/logo.vue';
import FooterHome from '../components/footerHome.vue';
import PublicTitle from '../components/PublicTitle.vue';
import { useRouter, useRoute } from 'vue-router';
import ScrollBoxCom from '../scrollBox.vue';
import { ref, watch, reactive, nextTick, defineComponent } from 'vue';
import { copyrightSave, copyrightInfo } from '@/api/templates/templates';
import { useProjectStore, commonDataStore } from '@/store';
import { storeToRefs } from 'pinia';
import { computed } from 'vue';

const parmas = reactive({
  value: '',
  pageNo: 1,
  pageSize: 100,
});
const topShow = ref(false);
const scrollBox = ref(null);
const percentage = ref(0);
const list = ref([]);
const total = ref(0);
const loading = ref(false);
const store = useProjectStore();
const Scrollwidth = ref();
const router = useRouter();
const route = useRoute();
const Description = ref('');
const init = async () => {
  try {
    if (loading.value) {
      return;
    }
    loading.value = true;
    let res = await goodsList(localStorage.getItem('projectId'), parmas);
    total.value = res.data.total;
    list.value = list.value.concat(res.data.data);
    // list.value = [];
    loading.value = false;
  } catch {
    loading.value = false;
  }
};
init();

let viewportwidth = window.innerWidth;
Scrollwidth.value = (viewportwidth / 900) * 715;

const getScrollWidth = computed(() => {
  let widths = (window.innerWidth / 900) * 715;
  return widths;
});

const handleScroll = (event) => {
  event.preventDefault(); // 阻止默认滚动行为
  const { deltaY } = event;

  // 获取滚动内容的 DOM 元素
  const contentEl = scrollBox.value;

  // 将滚动盒子向前滚动
  contentEl.scrollLeft += deltaY;
  if (contentEl.scrollWidth > contentEl.clientWidth) {
    if (
      contentEl.scrollWidth < contentEl.scrollLeft + contentEl.clientWidth + 100 &&
      !loading.value &&
      list.value.length < total.value
    ) {
      parmas.pageNo = parmas.pageNo + 1;
      init();
    }
    nextTick(() => {
      const { scrollLeft, clientWidth, scrollWidth } = scrollBox.value;
      if (scrollLeft > 100) {
        topShow.value = true;
      }
      if (scrollLeft < 100) {
        topShow.value = false;
      }
      const newScrollPercentage = Math.floor((scrollLeft / (scrollWidth - clientWidth)) * 100);
      percentage.value = newScrollPercentage == 99 ? 100 : newScrollPercentage;
    });
  }
};
const emitTop = () => {
  //点击回到列表最左侧
  scrollBox.value.scrollLeft = 0;
  percentage.value = 0;
  topShow.value = false;
};
const pathLink = (url?: string) => {
  if (!url) {
    return;
  }
  window.open(url, '_blank');
};
const blankHome = () => {
  router.push({ name: route.meta.loopType ? 'exhibitionHome' : 'templateedit' });
};
</script>

<style scoped lang="less">
.Cultural-box {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 120px 0;
  padding-bottom: 0px;
  background-size: 100% 100%;
}
.logo-box{ 
  width: 287px;
  height: 26px;  
  position: absolute;
  bottom: 20px;
  left: calc(50% - 143.5px);
   background-size: 100% 100%;
  background-repeat: no-repeat;
}
.copyright-heard {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 56px;
  margin-bottom: 50px;
  padding: 0 100px;
  .heard-title {
    display: flex;
    align-items: center;
    i {
      font-size: 36px;
      line-height: 36px;
      color: rgba(87, 125, 134, 1);
    }
    span {
      margin: 0 8px;
      font-family: SourceHanSerifCN-Bold;
      font-size: 36px;
      line-height: 56px;
      text-align: center;
      color: rgba(87, 125, 134, 1);
    }
  }

  .freeIcon {
    cursor: pointer;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 100px;
    font-size: 34px;
    line-height: 34px;
    color: rgba(87, 125, 134, 1);
  }
}
.right-scroll {
  display: flex;
  width: 100%;
  padding-top: 12px;
  min-height: 368px;
  padding-left: 0px;
}
:deep(.unit-exbi-remarks-info-remarks) {
  min-height: 368px;
  padding-top: 0 !important;
}
:deep(.solid-box-parent) {
  margin-top: 62px;
  margin-right:120px;
}
.right-scroll::-webkit-scrollbar {
  display: none;
}
.item-parent {
  margin-right: 20px;
  height: 366px;
}
.item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 280px;
  height: 366px;
  background: rgba(255, 255, 255, 1);
  box-shadow: 0px 4px 13px 0px rgba(87, 125, 134, 0.1);

  transition: all 0.3s;
}

.item-img-box {
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 280px;
  height: 280px;
  background: rgba(146, 175, 168, 0.34);
}

.item-img {
  position: relative;
  z-index: 30; 
  width: 280px;
  height: 280px; 
  max-height: 280px;
  object-fit: contain;
  transition: all 0.3s;
}
.item-parent:hover {
  .item-img {
    transform: scale(1.2);
  }
}
.item-name {
  width: 100%; 
  font-family: SourceBold !important;
  font-size: 18px;
  color: rgba(63, 95, 92, 1);
  line-height: 28px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 10px;
  margin-bottom: 4px;
  text-indent: 0rem !important;
  padding: 0 24px;
  height: 28px;
}
.item-btm {
  width: 100%;
  padding: 0 24px;
  display: flex;
  align-items: baseline;
}
.item-title1 {
  font-family: PingFangSC, PingFang SC;
  font-weight: 400;
  font-size: 14px;
  color: rgba(63, 95, 92, 1);
}
.item-title2 {
  margin-right: 2px;
  font-family: PingFangSC, PingFang SC;
  font-weight: 500;
  font-size: 22px;
  color: rgba(63, 95, 92, 1);
  line-height: 34px;
}

.item-title3 {
  font-family: PingFangSC, PingFang SC;
  font-weight: 400;
  font-size: 12px;
  color: rgba(63, 95, 92, 0.6);
  line-height: 18px;
  margin-left: 1px;
}
.item-title4 {
  font-family: PingFangSC, PingFang SC;
  font-weight: 400;
  font-size: 16px;
  color: rgba(63, 95, 92, 0.6);
  line-height: 34px;
}
.solidBorder-child {
  width: 100%;
  height: 4px;
  background: rgba(190, 212, 206, 1);
  border-radius: 1px;
  opacity: 0.5;
}
:deep(.templatestyle1-scroll-box-tumb) {
  display: flex;
  align-items: center;
  img {
    width: 24px;
    height: 24px;
  }
}
.is-null {
  margin: 0 auto;
  // margin-left: -100px;
  margin-top: 200px;
  text-align: center;
  span {
    font-size: 20px;
    line-height: 32px;
    color: #92AFA8;
  }
}
.item-max {
  margin-right: 100px;
}
:deep(.unit-exbit-null-remarks-info) {
  margin-left: 100px;
  margin-right: 0px;
  width: auto;
}
:deep(.right-scroll) {
  padding-right: 0px !important;
}
@media screen and (min-width: 2150px) {
  :deep(.unit-exbit-null-remarks-info) {
    margin-left: 100px;
    margin-right: 50px;
    width: auto;
  }
}
@media screen and (max-width: 900px) {
  :deep(.unit-exbit-null-remarks-info) {
    margin-left: 100px;
    margin-right: 50px;
    width: auto;
  }
}
.footer-logo-box {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 276px;
  height: 24px;
}
</style>